package upms.api.feign;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import upms.api.fallback.RemoteUserFallback;
import upms.api.vo.UsersVo;

import java.util.Set;

@FeignClient(contextId = "remoteUserService", value = "upms-biz", fallbackFactory = RemoteUserFallback.class)
public interface RemoteUserService {

    /**
     * 通过用户名查询用户信息
     */
    @GetMapping("/user/info/{username}")
    @Cacheable(cacheNames = "user-info", key = "#username")
    UsersVo info(@PathVariable("username") String username);

    /**
     * 通过用户名查询角色信息
     */
    @GetMapping("/user/role/{username}")
    @Cacheable(cacheNames = "user-role", key = "#username")
    Set<String> role(@PathVariable("username") String username);
}